<template>

  <div class="discover-view">
    <div class="icon">
      <i class="icon-search"></i>
    </div>
    <div class="tab-bar">
      <router-link to="/discover/read-month/1">阅读</router-link>
      <router-link to="/discover/photo-article">图文</router-link>
      <router-link to="/discover">专题</router-link>
      <router-link to="/discover/hot">热榜</router-link>
      <router-link to="/discover/read-month/3">问答</router-link>
      <router-link to="/discover/read-month/4">音乐</router-link>
      <router-link to="/discover/read-month/5">影视</router-link>
      <router-link to="/discover/read-month/8">电台</router-link>
      <router-link to="/discover/square">小记</router-link>
      <router-link to="/discover/author">作者</router-link>
    </div>

    <DiscoverList :topicList="topicList"></DiscoverList>
    <keep-alive>
      <transition :name="transitionName">
        <router-view :play-status="playStatus"></router-view>
      </transition>
    </keep-alive>

  </div>
</template>

<script>
const dateTypes = {
  0: "阅读",
  1: "图文",
  2: "专题",
  3: "热榜",
  4: "问答",
  5: "音乐",
  6: "影视",
  7: "电台",
  8: "小记",
  9: "作者",
};

import DiscoverList from "./DiscoverList.vue";

export default {
  name: "DiscoverView",
  props: {
    playStatus: Boolean,
  },
  data() {
    return {
      loading: true,
      tab: 2,
      dateTypesArr: [],
      topicList: [],
      currentIndex: 0,
      tabName: "",
      transitionName: "slide-left",
    };
  },
  activated() {
    // this.getDiscoverListData();
  },
  mounted() {
    this.dateTypesArr = dateTypes;
    this.getDiscoverListData();
  },
  watch: {
    // tab(val, o) {
    //   this.currentIndex = val;
    //   console.log("新"+val);
    //   console.log("旧" + o);
    // },
  },
  methods: {
    // 获取专题列表数据
    async getDiscoverListData() {
      let { data } = await this.$axios.get(
        "https://apis.netstart.cn/one/banner/list/4"
      );
      this.topicList = data.data;
    },
  },
  components: {
    DiscoverList,
  },
};
</script>

<style lang="scss" scoped>
.discover-view {
  position: fixed;
  top: 0;
  right: 0;
  width: 100vw;
  height: 100vh;
  overflow: auto;
 

  .icon {
    position: fixed;
    top: 0px;
    right: 0px;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 50px;
    height: 42px;
    background-color: #fff;
    z-index: 2;

    .icon-search {
      display: block;
      width: 20px;
      height: 20px;
      transform: translateY(3px);
      background-image: url("../../assets/img/discover_icon_search.png");
      background-repeat: no-repeat;
      background-size: cover;
      // background-color: #fff;
    }
  }
  .tab-bar {
    position: fixed;
    top: 0;
    height: 50px;
    display: flex;
    align-items: center;
    padding: 0 20px 0;
    padding-right: 50px;
    background-color: #fff;
    overflow-x: auto;
    // overflow: hidden;
    a {
      // width: 20px;
      flex: 0 0 40px;
      margin-right: 15px;
      display: inline-block;
      // margin:0 20px;
      text-decoration: none;
      color: black;
    }
    .router-link-exact-active {
      font-size: 20px;
      font-weight: 700;
    }
  }
}
.loading {
  margin: 20px auto;
}
</style>